<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link rel="stylesheet" type="text/css" href="/public/static/h-ui/css/H-ui.min.css" />
<body>
<div id="container" style="border: 1px solid #000000;min-width:300px;min-height:467px;"></div>
<input class="btn btn-primary radius" onclick="submit_pos()" type="button" value="确定">
<input type="hidden" id="lat" value="34.618130">
<input type="hidden" id="lng" value="112.454020">
<script type="text/javascript" src="/public/js/jquery-2.1.1.js"></script>
<script type="text/javascript" src="/public/static/layer/2.4/layer.js"></script>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=UFVBZ-TCCCF-GWTJD-N3VQY-JHEQH-ZZBDM"></script>
<script>
    $(function(){
        init();
    });
    function init() {
        var center;
        center = new qq.maps.LatLng(34.618130,112.454020);
        var map = new qq.maps.Map(document.getElementById("container"),{
            center:center,
            zoom: 14
        });
        var infoWin = new qq.maps.InfoWindow({
            map: map
        });
//    infoWin.open();
//    infoWin.setContent('Hello world');
//    infoWin.setPosition(map.getCenter());
        var marker1 = new qq.maps.Marker({
            position: center,
            map: map
        });
        //添加监听事件   获取鼠标单击事件
        qq.maps.event.addListener(map, 'click', function(event) {
            marker1.setMap(null);
            var marker=new qq.maps.Marker({
                position:event.latLng,
                map:map
            });
            qq.maps.event.addListener(map, 'click', function(event) {
                marker.setMap(null);
            });
            console.log(marker.position);
            $("#lat").val(marker.position.lat);
            $("#lng").val(marker.position.lng);
        });
    }
    function submit_pos() {
        parent.get_position($("#lat").val(),$("#lng").val());
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</body>
</html>